package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"lessson/internal/config"
	"lessson/internal/middleware"
	"order_srv/order"
	"order_srv/orderclient"
)

type ServiceContext struct {
	Config    config.Config
	AuthToken rest.Middleware
	OrderSrv  order.OrderClient
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:    c,
		AuthToken: middleware.NewAuthTokenMiddleware().Handle,
		OrderSrv:  orderclient.NewOrder(zrpc.MustNewClient(c.OrderSrv)),
	}
}
